
<!--
All rights Reserved, Designed By www.youyacao.com
@Description:七牛云配置
@author:成都市一颗优雅草科技有限公司
@version V4.2
注意：本前端源码遵循 MIT开源协议本内容仅限于个人参考，禁止用于其他的商业用途
需要商业用途或者定制开发等可访问songshu.youyacao.com   联系QQ:422108995 23625059584
开源gitee地址：https://gitee.com/youyacao/songshu-video-page
 -->

<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <i class="el-icon-lx-calendar"></i> 七牛云配置
        </el-breadcrumb-item>
        <el-breadcrumb-item>七牛云配置</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <div class="form-box">
        <el-form ref="form" :model="form" label-width="230px">
          <el-form-item>
            <el-row>
              七牛云官网：
              <el-link
                :href="'https://www.qiniu.com/'"
                type="primary"
                target="_blank"
              >https://www.qiniu.com/
              </el-link>
            </el-row>
          </el-form-item>
          <el-form-item label="是否启用七牛云">
            <el-tooltip class="item" effect="dark" content="启用后将上传至七牛云，上传速度将下降" placement="top">
              <el-radio v-model="form.use_qiniu" label="1">启用</el-radio>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="关闭后上传至本地服务器，速度根据带宽决定" placement="top">
              <el-radio v-model="form.use_qiniu" label="0">关闭</el-radio>
            </el-tooltip>

          </el-form-item>
          <el-form-item label="accesskey">
            <el-input v-model="form.accesskey"></el-input>
          </el-form-item>
          <el-form-item label="secretkey">
            <el-input v-model="form.secretkey"></el-input>
          </el-form-item>
          <el-form-item label="bucket">
            <el-input v-model="form.bucket"></el-input>
          </el-form-item>
          <el-form-item label="domain">
            <el-input v-model="form.domain"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">提交</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
    import qs from 'Qs'

    export default {
        name: 'baseform',
        data () {
            return {
                form: {}
            }
        },
        created () {
            this.getData()
        },
        methods: {
            getData () {
                this.$api.config.get({}).then(res => {
                    this.form = res.data
                })
            },
            onSubmit () {
                var data = []
                for (let item in this.form) {
                    data[`config[${item}]`] = this.form[item]
                }
                console.log(data)
                this.$api.config.set(qs.stringify(data)).then(res => {
                    console.log(res.data)
                })
                this.$message.success('提交成功！')
            }
        }
    }
</script>
